<?php
namespace App\Commen;

use Symfony\Component\DependencyInjection\ContainerInterface;

class MqCommen
{
    private $container;
    private $jobConn;
    /** @var  \Monolog\Logger */
    private $logger;

    /**
     * UserCommen constructor.
     * @param ContainerInterface $container
     * @param $logger
     */
    public function __construct($container, $logger)
    {
        $this->container = $container;
        $this->jobConn = $container->get('doctrine.dbal.customer_connection');
        $this->logger = $logger;
    }

    /**
     * 把消息写入到队列
     * @param $data
     * @param $touteKey
     */
    public function writeMq($data, $routingKey)
    {
        $producer = $this->container->get('old_sound_rabbit_mq.task_producer');
        $producer->setContentType('application/json');
        $producer->publish(json_encode($data), $routingKey);
    }
}